package com.clstu.ploy_.ployparameter;

public class PloyParameter {
    public static void main(String[] args) {
        PloyParameter ployParameter = new PloyParameter();
        Worker jack = new Worker("jack", 20);
        Manager frank = new Manager("frank", 25, 20000);
        Employee king = new Employee("King", 30);
        ployParameter.showAnnual(jack);
        ployParameter.showAnnual(frank);
        ployParameter.showAnnual(king);
        ployParameter.testWork(jack);
        ployParameter.testWork(frank);
        ployParameter.testWork(king);

        System.out.println("abc".equals("abc"));//equals() 不能用于判断基本类型
    }

    public void showAnnual(Employee e){//动态绑定机制，优先调用运行类型的方法
        System.out.println(e.getName()+" Annual ： "+e.getAnnual());
    }

    public void testWork(Employee e){//多态参数
        if(e instanceof Worker) ((Worker) e).work();;//向下转型，调用特有方法
        if(e instanceof Manager) ((Manager) e).manage();//向下转型
    }
}
